<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-level-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">等级名称：</label>
				<div class="col-sm-8">
					<input id="levelName" name="levelName" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">下限值：</label>
				<div class="col-sm-8">
					<input id="levelFloor" name="levelFloor" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">上限值：</label>
				<div class="col-sm-8">
					<input id="levelCeil" name="levelCeil" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" class="form-control" type="text">
				</div>
			</div>
			<!--<div class="form-group">
				<label class="col-sm-3 control-label">添加用户：</label>
				<div class="col-sm-8">
					<input id="createBy" name="createBy" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">更新用户：</label>
				<div class="col-sm-8">
					<input id="updateBy" name="updateBy" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">添加时间：</label>
				<div class="col-sm-8">
					<input id="createTime" name="createTime" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">更新时间：</label>
				<div class="col-sm-8">
					<input id="updateTime" name="updateTime" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">删除标记：</label>
				<div class="col-sm-8">
					<input id="delFlag" name="delFlag" class="form-control" type="text">
				</div>
			</div>-->
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "gxgw_modules/level"

		var msg = "";
		jQuery.validator.addMethod("minNum",function(value,element,floor){
			var min = floor[0].value;
			console.log(min);
			if(min && value <= min){
				msg = "请输入大于 "+min+" 的数值";
				return this.optional(element) || false;
			}
		},function () {
			return msg;
		})
		jQuery.validator.addMethod("maxNum",function(value,element,ceil){
			var max = ceil[0].value;
			console.log(max);
			if(max && value >= max){
				msg = "请输入小于 "+max+" 的数值";
				return this.optional(element) || false;
			}
		},function () {
			return msg;
		})
		$("#form-level-add").validate({
			rules:{
				levelFloor: {
					required: true,
					number: true,
					maxNum: [levelCeil]
				},
				levelCeil: {
					required: true,
					number: true,
					minNum: [levelFloor]
				}
			}
		});
		
		function submitHandler() {
			console.log(parseFloat($('#levelFloor').val()), parseFloat($('#levelCeil').val()))
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-level-add').serialize());
	        }
	    }
	</script>
</body>
</html>
